package zwp.exercise.service.exercisedemo.chapterFour;

import java.util.Scanner;

/**
 * @Author zwp14
 * @create 2025/10/28 22:20
 * @description if和switch语句练习
 */
public class IfAndSwitchExerciseDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
         // 划分成绩等级
         exerciseDemoOne(scanner);

         // 判断月份对应的季节
         exerciseDemoTwo(scanner);
        scanner.close();
    }

    /**
     * 划分成绩等级 if else 语句
     * a≥90 “优秀”，90> a ≥80 “良好”， 80>a≥60 “合格”， 60>a“不合格”
     */
    private static void exerciseDemoOne(Scanner scanner) {
        System.out.println("-------------------------划分成绩等级练习-------------------------");
        System.out.println("请输入成绩：");
        double great = scanner.nextDouble();
        if (great>=90 ){
            System.out.println("优秀");
        }else if (90 > great && great >=80 ){
            System.out.println("良好");
        }else if (80 > great && great >= 60){
            System.out.println("合格");
        } else if (60 > great && great >= 0) {
            System.out.println("不合格");
        }else if (0 > great){
            System.out.println("成绩不合法");
        }else {
            System.out.println("输入不合法！");
        }

        System.out.println("############################################################333");
    }

    /**
     * 判断月份对应的季节  switch语句
     */
    private static void exerciseDemoTwo(Scanner scanner) {
        System.out.println("-------------------------判断月份对应的季节-------------------------");
        System.out.println("请输入你要查询的月份：");
        int month = scanner.nextInt();

        switch (month){
            case 1:
            case 2:
            case 3:
                System.out.println("春季！");
                break;
            case 4:
            case 5:
            case 6:
                System.out.println("夏季！");
                break;
            case 7:
            case 8:
            case 9:
                System.out.println("秋季！");
                break;
            case 10:
            case 11:
            case 12:
                System.out.println("冬季！");
                break;
            default:
                System.out.println("输入不合法！");
        }
        System.out.println("############################################################333");
    }
}
